import 'package:flutter/material.dart';
import 'package:nyh_motorcade_app/styles/colors.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:nyh_motorcade_app/widgets/text_button_with_icon.dart';

class TextWithIcon extends StatelessWidget {
  final String text;
  final TextStyle? textStyle;
  final String iconName;
  final double? iconWidth;
  final double? iconHeight;
  final Color? iconColor;
  final IconTextAlignment? iconTextAlignment;
  final double? textIconPadding;

  TextWithIcon({
    required this.text,
    required this.iconName,
    this.iconWidth,
    this.iconHeight,
    this.iconColor,
    this.textStyle,
    this.iconTextAlignment = IconTextAlignment.iconLeftTextRight,
    this.textIconPadding = 5.0,
  });

  @override
  Widget build(BuildContext context) {
    TextStyle defaultTextStyle = TextStyle(
      color: Colours.color_6f7082,
      fontSize: 12.sp,
    );
    switch (iconTextAlignment) {
      case IconTextAlignment.iconTopTextBottom:
        return Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Image.asset(
              iconName,
              height: iconHeight,
              width: iconWidth,
              color: iconColor,
            ),
            SizedBox(width: textIconPadding),
            Flexible(child: Text(text, style: textStyle ?? defaultTextStyle))
          ],
        );
      case IconTextAlignment.iconBottomTextTop:
        return Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Flexible(child: Text(text, style: textStyle ?? defaultTextStyle)),
            SizedBox(width: textIconPadding),
            Image.asset(
              iconName,
              height: iconHeight,
              width: iconWidth,
              color: iconColor,
            )
          ],
        );
      case IconTextAlignment.iconLeftTextRight:
        return Row(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Image.asset(
              iconName,
              height: iconHeight,
              width: iconWidth,
              color: iconColor,
            ),
            SizedBox(width: textIconPadding),
            Flexible(child: Text(text, style: textStyle ?? defaultTextStyle))
          ],
        );
      case IconTextAlignment.iconRightTextLeft:
        return Row(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Flexible(child: Text(text, style: textStyle ?? defaultTextStyle)),
            SizedBox(width: textIconPadding),
            Image.asset(
              iconName,
              height: iconHeight,
              width: iconWidth,
              color: iconColor,
            )
          ],
        );
      default:
        return Row(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Image.asset(
              iconName,
              height: iconHeight,
              width: iconWidth,
              color: iconColor,
            ),
            SizedBox(width: textIconPadding),
            Flexible(child: Text(text, style: textStyle ?? defaultTextStyle))
          ],
        );
    }
  }
}
